package com.eden;

import com.eden.entity.BasisInfo;
import com.eden.util.EntityInfoUtil;
import com.eden.util.Generator;
import com.sun.org.apache.bcel.internal.generic.ALOAD;

import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.Date;

/**
 * ClassName: AppMain
 * Package: com.eden
 * Description: todo
 * Date:  2020/10/19 9:17
 *
 * @Author: 李秉林
 */
public class AppMain {
	// 基础信息：项目名、作者、版本
	public static final String PROJECT = "skyworth";
	public static final String AUTHOR = "Eden";
	public static final String VERSION = "V1.0";
	public static final String TIME = "2019年10月16日";
	public static final String AGILE = new Date().getTime() + "";
	// 数据库连接信息：连接URL、用户名、秘密、数据库名
	public static final String URL = "jdbc:mysql://127.0.0.1:3306/eden?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8";
	public static final String NAME = "root";
	public static final String PASSWORD = "le98i3nf";
	public static final String DATABASE = "eden";
	public static final String TABLE = "payment";
	// 类信息：类名、对象名（一般是【类名】的首字母小些）、类说明、时间
	public static final String ENTITY_NAME = "Payment";
	public static final String ENTITYCOMMENT = "Payment";
	public static final String MAPPER_NAME = "PaymentMapper";
	public static final String MAPPER_XML_NAME = "PaymentMapper";
	public static final String SERVICE_NAME = "PaymentService";
	public static final String CONTROLLER_NAME = "PaymentController";
	// 路径信息，分开路径方便聚合工程项目，微服务项目
	public static final String ENTITY_URL = "com.eden.entity";
	public static final String MAPPER_URL = "com.eden.mapper";
	public static final String MAPPER_XML_URL = "com.eden.mapper";
	public static final String SERVICE_URL = "com.eden.service";
	public static final String CONTROLLER_URL = "com.eden.controller";
	// 真实路径信息
	public static final String ENTITY_REAL_URL = "F:\\test4\\r1231\\";
	public static final String MAPPER_REAL_URL = "F:\\test4\\r1231\\";
	public static final String MAPPER_REAL_XML_URL = "F:\\test4\\r1231\\";
	public static final String SERVICE_REAL_URL = "F:\\test4\\r1231\\";
	public static final String CONTROLLER_REAL_URL = "F:\\test4\\r1231\\";
	
	public static void main(String[] args) {
		BasisInfo basisInfo = new BasisInfo(
			 PROJECT, AUTHOR, VERSION, TIME, AGILE, URL, NAME, PASSWORD, DATABASE,
			 TABLE, ENTITY_NAME, ENTITYCOMMENT, ENTITY_URL, MAPPER_NAME, MAPPER_URL, MAPPER_XML_NAME, MAPPER_XML_URL,
			 SERVICE_NAME, SERVICE_URL, CONTROLLER_NAME, CONTROLLER_URL
		);
		try {
			basisInfo = EntityInfoUtil.getInfo(basisInfo);
			//开始生成文件
			String entity = Generator.createEntity(ENTITY_REAL_URL, basisInfo).toString();
			String mapper = Generator.createMapper(MAPPER_REAL_URL, basisInfo).toString();
			String mapperXML = Generator.createMapperXML(MAPPER_REAL_XML_URL, basisInfo).toString();
			String service = Generator.createService(SERVICE_REAL_URL, basisInfo).toString();
			String controller = Generator.createController(CONTROLLER_REAL_URL, basisInfo).toString();
			
			System.out.println("***********************/////////////////////////************************");
			System.out.println(entity);
			System.out.println(mapper);
			System.out.println(mapperXML);
			System.out.println(service);
			System.out.println(controller);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
